/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.rpc.simright.constants.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 数巧解析任务状态枚举
 *
 * @author lj
 * @date 2025-9-23
 */
@AllArgsConstructor
@Getter
public enum SimrightTaskStatusEnum {
    SUCCESS("SUCCESS", "成功"),
    RUNNING("RUNNING", "运行中"),
    FAILURE("FAILURE", "失败");

    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        SimrightTaskStatusEnum simrightResponseCodeEnum = forValue(value);
        if (simrightResponseCodeEnum == null) {
            return null;
        }
        return simrightResponseCodeEnum.getDesc();
    }

    public static SimrightTaskStatusEnum forValue(String value) {
        if (value == null) {
            return null;
        }
        for (SimrightTaskStatusEnum simrightResponseCodeEnum : SimrightTaskStatusEnum.values()) {
            if (simrightResponseCodeEnum.getValue().equalsIgnoreCase(value)) {
                return simrightResponseCodeEnum;
            }
        }
        return null;
    }

    public static SimrightTaskStatusEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (SimrightTaskStatusEnum simrightResponseCodeEnum : SimrightTaskStatusEnum.values()) {
            if (desc.equals(simrightResponseCodeEnum.getDesc())) {
                return simrightResponseCodeEnum;
            }
        }
        return null;
    }
}
